package com.su.lesson02;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class textText01 {
    public static void main(String[] args) {
        //启动！
        new MyFrame();
    }
}
class MyFrame extends Frame {
    public MyFrame(){
        TextField textField = new TextField();
        add(textField);

        //监听这个文本框输入的文字
        MyActionListener02 myActionListener02 = new MyActionListener02();
        textField.addActionListener(myActionListener02);
        //设置替换编码
        textField.setEchoChar('#');
        setVisible(true);
        pack();
    }
}
class MyActionListener02 implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) {
        TextField field = (TextField)e.getSource(); //获的一些资源
       System.out.println( field.getText());//获得输入框的文本
        field.setText("");//清空文本框
    }
}
